package yangan.controller;

import app.nbdevices.modle.revModle.DataChangedModle;
import app.nbdevices.modle.revModle.ServiceModle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import yangan.modle.revModle.RevYanganCycleData;
import yangan.modle.revModle.RevYanganEventData;
import yangan.service.IYanganService;

@Component
public class YanganController {

    @Autowired
    @Qualifier("YanganService")
    IYanganService svcYangan;

    public void yEventReportData(DataChangedModle dataChangedModle){
        ServiceModle service=dataChangedModle.getService();
        RevYanganEventData revEventReportData=service.getData()
                .toJavaObject(RevYanganEventData.class);
        svcYangan.saveEventReportData(revEventReportData,dataChangedModle.getDeviceId());
    }

    public void yCycleReportData(DataChangedModle dataChangedModle){
        ServiceModle service=dataChangedModle.getService();
        RevYanganCycleData revCycleReportData=service.getData()
                .toJavaObject(RevYanganCycleData.class);
        svcYangan.saveCycleReportData(revCycleReportData,dataChangedModle.getDeviceId());
    }
}
